class Solution {
public:
    bool findNumberIn2DArray(vector<vector<int>>& matrix, int target) {
        if(matrix.size() == 0)return false;
        int n = matrix.at(0).size();
        int m = matrix.size();
        size_t i = 0, j = m-1;
        while(i < n && j >= 0){
            if(target == matrix.at(j).at(i))return true;
            else if(target < matrix.at(j).at(i))j--;
            else i++;
        }
        return false;
    }
};